const data3 = [
    {
        id: 1,
        name: '前端',
        children: [
            {
                id: 2,
                name: 'html',
                children: [
                    { id: 5, name: 'vue', children: [] },
                    { id: 6, name: 're', children: [] },
                ]
            },
            {
                id: 3,
                name: 'html',
                children: [
                    { id: 7, name: 'vue', children: [] },
                    { id: 8, name: 're', children: [] },
                ]
            }
        ]
    }
]
let route = []
function printRoutes(data,targetName) {
    function recur(data,route,targetName) {
        const {id,name,children} = data
        route += id
        if (name === targetName) {
            res.push(route)
            return
        }
        if (children && children.length > 0) {
            children.forEach(item => {
                recur(item,route + '->', targetName)
            })
        }

    }
    let res = []
    recur(data,'',targetName)
    return res

}

let resArr = []
//? data是数组 在这里用循环弄
for (let i = 0; i < data3.length; i ++) {
    resArr.push(printRoutes(data3[i], 'vue'))
}
console.log(resArr);
